<template>
	<view class="flex-col page">
		<view class="flex-col group">
			<view class="justify-between group_1">
				<view class="flex-row" @click="show = true">
					<picker mode="date" fields='month' :value="currentDate" @change="bindDateChange">
						<view class="uni-input">
							<text class="text_1">{{currentDate}}</text>
							<image :src="$IMG_URL+'16557868142922931567.png'" class="image_1" />
						</view>
					</picker>
				</view>
				<text class="text_2">巡检次数：{{num}}次</text>
			</view>
			<view class="flex-col list" v-if="this.list != '' || this.list != null">
				<view class="flex-col list-item" :key="i" v-for="(item, i) in list">
					<view class="justify-between group_3">
						<text class="text_3">订单编号：{{item.ordersNumber}}</text>
						<text class="text_5" v-if="item.ordersStatus == 1">待付款</text>
						<text class="text_5" v-else-if="item.ordersStatus == 2">待完善</text>
						<text class="text_5" v-else-if="item.ordersStatus == 3">进行中</text>
						<text class="text_5" v-else-if="item.ordersStatus == 4">待评价</text>
						<text class="text_5" v-else-if="item.ordersStatus == 5">已完成</text>
						<text class="text_5" v-else>已取消</text>
					</view>
					<view class="flex-row group_4">
						<image :src="item.address" class="image_2" />
						<text class="text_7">{{item.consumerName}}</text>
					</view>
					<text class="text_9">巡检服务订单</text>
					<text class="text_11">第{{item.nums}}次巡检（{{item.processName}}）</text>
					<text
						class="text_13">{{item.provinceName}}{{item.cityName}}{{item.districtName}}{{item.position}}</text>
					<view class="justify-center group_5">
						<text class="text_15">上门巡检时间：{{item.inspectionDate}}</text>
					</view>
				</view>
				<view @click="seemore" style="position: fixed; bottom: 80rpx;  width: 100%; ">
					<uni-load-more color="#007AFF" :status="status" :content-text="contentText" />
				</view>
			</view>
			<view v-else-if="this.list ==''">
				<u-empty style="height: 76vh" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png">
				</u-empty>
			</view>
		</view>


	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				list: [],
				show: false,
				date: '',
				num: "",
				currentDate: new Date().toISOString().slice(0, 7),
				contentText: {
					contentdown: '点击查看更多',
					contentrefresh: '加载中',
					contentnomore: '没有更多了'
				},

				status: 'more',
				pageNum: 1
			};
		},
		onReady() {

		},
		created() {
			let arr = [];
			arr = this.currentDate.split('-')
			let arrstr = arr[0] + arr[1]
			this.getdate(arrstr);
			uni.startPullDownRefresh();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods: {
			seemore() {
				this.pageNum++;
				let arr = [];
				arr = this.currentDate.split('-')
				let arrstr = arr[0] + arr[1]
				// this.getdate(arrstr);
				this.$http('common.minePrevious', {
					dateStr: arrstr,
					pageSize: 10,
					pageNum: this.pageNum
				}).then(res => {
					// console.log(res)
					if (res.code == 200) {
						this.num = res.msg;

						if (res.data != '') {
							this.list.push(...res.data);
						} else {
							this.status = 'contentnomore'
						}
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'error'
						})
					}
				})
			},
			Back() {
				let pageNum = 2
				let pages = getCurrentPages(); // 当前页面
				let beforePage = pages[pages.length - pageNum];
				uni.navigateBack({
					success: function() {
						beforePage.$vm.$refs.mine.getinfo();
					}

				})
			},
			onPullDownRefresh() {
				let arr = this.currentDate.split('-')
				let arrstr = arr[0] + arr[1]
				this.getdate(arrstr)
				setTimeout(function() {
					uni.stopPullDownRefresh();
				}, 1000);
			},
			getdate(arrstr) {
				this.$http('common.minePrevious', {
					dateStr: arrstr,
					pageSize: 10,
					pageNum: this.pageNum
				}).then(res => {
					console.log(res)
					if (res.code == 200) {
						this.num = res.msg;
						this.list = res.data;
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'error'
						})
					}
				})
			},
			bindDateChange: function(e) {
				let newa = e.detail.value;
				newa = newa.split('-');
				let arrstr = newa[0] + newa[1]
				this.currentDate = newa[0] + '年' + newa[1] + '月';
				this.getdate(arrstr)
			},
		},
	};
</script>

<style scoped lang="scss">
	.back-w {
		display: flex;
		flex-direction: row;
		padding-top: 50rpx;
		/* align-items: center; */
		width: 100vw;
		height: 90rpx;
		background-color: #ffffff;
	}

	.f-w-l {
		display: flex;
		flex-direction: row;
		font-weight: bold;
		margin-left: 33%;
	}

	.list-item {
		padding: 0 23rpx 34rpx 24rpx;
		background-color: #ffffff;
		border-radius: 16rpx;
	}

	.group_3 {
		padding: 30rpx 0 27rpx;
		border-bottom: solid 1rpx #eeeeee;
	}

	.group_4 {
		margin-top: 24rpx;
	}

	.text_9 {
		font-weight: bold;
		margin-top: 21rpx;
		align-self: flex-start;
		color: #333333;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}

	.text_11 {
		font-weight: 500;
		margin-top: 24rpx;
		align-self: flex-start;
		color: #1d6aff;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.text_13 {
		margin-top: 22rpx;
		color: #333333;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
	}

	.group_5 {
		margin-top: 27rpx;
		position: relative;
	}

	.text_3 {
		margin-top: 6rpx;
		color: #666666;
		font-size: 26rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.text_5 {
		margin-bottom: 6rpx;
		color: #1d6aff;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.image_2 {
		border-radius: 50%;
		width: 64rpx;
		height: 64rpx;
	}

	.text_7 {
		font-weight: bold;
		margin-left: 16rpx;
		margin-top: 10rpx;
		color: #333333;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.text_15 {
		color: #333333;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
		position: absolute;
		left: 0;
		top: 50%;
		transform: translateY(-50%);
	}

	.text_17 {
		color: #333333;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
	}

	.page {
		background-color: #f6f7f9ff;
		width: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		height: 95vh;
	}

	.group {
		padding: 29rpx 24rpx 64rpx;
		flex: 1 1 auto;
		overflow-y: auto;
	}

	.group_1 {
		padding-left: 8rpx;
		padding-right: 6rpx;
	}

	.list {
		margin-top: 32rpx;
	}

	.text_2 {
		font-weight: 800;
		color: #1d6aff;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}

	.list-item:not(:first-of-type) {
		margin-top: 20rpx;
	}

	.text_1 {
		font-weight: 400;
		color: #191919;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}

	.image_1 {
		margin-left: 10rpx;
		margin-top: 12rpx;
		flex-shrink: 0;
		width: 28rpx;
		height: 28rpx;
	}
</style>
